<?php
// swoole基于多进程模型
/**
 * 11 个进程
 *Threads:   1 total,   0 running,   1 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.1 us,  2.5 sy,  0.0 ni, 96.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  15907.3 total,   1115.7 free,  10526.5 used,   4265.1 buff/cache
MiB Swap:   3072.0 total,   3069.4 free,      2.6 used.   4778.3 avail Mem
 */
// 测试： ab -k -c 100 -n 10000 http://127.0.0.1:9501/
// 吞吐量：138005.27
$http = new Swoole\Http\Server('0.0.0.0', 9501);
$http->set([
    'worker_num' => 11,
    'reactor_num' => 1
]);
\Co::set(['hook_flags'=> SWOOLE_HOOK_ALL]);
$http->on('Request', function ($request, $response) {
    $response->end('hello, world');
});

$http->start();